package p100;

public class Leetcode_121 {
    public int maxProfit(int[] prices) {
        if (prices.length <= 1) {
            return 0;
        }
        int min = prices[0], max = 0;
        for (int price : prices) {
            max = Math.max(max, price - min);
            min = Math.min(min, price);
        }
        return max;
    }

    public static void main(String[] args) {
        Leetcode_121 l = new Leetcode_121();
        System.out.println(l.maxProfit(new int[]{1, 1}));

    }
}
